<!--
 * @Author: ChunLai
 * @Date: 2022-04-15 10:45:11
 * @LastEditTime: 2025-09-12 10:38:54
 * @Description: 回访操作弹窗
 * @FilePath: \02.bldinsure\src\views\result\components\ShareMask.vue
-->
<template>
  <div class="mask">
    <div class="_modal">
      <div class="_modal-header">
        <div class="flex-lr">
          <span class="lineh1">投保人填写</span>
          <MsImgIcon name="cross" @click.native="$emit('close')" />
        </div>
        <div class="p_label">
          为了保证合规性，请确认是 <i>{{ uMsg.name }}</i> 填写的信息
        </div>
      </div>
      <div class="_modal-content">
        <div class="pic_sign"></div>
      </div>
      <div class="_modal-footer">
        <span>
          <span class="name_c ftw5">{{ uMsg.name }}</span> 在身边？</span
        >
        <span class="_model_btn" @click="writeNow()">立即填写</span>
      </div>
      <div class="_modal-footer mt10">
        <span>
          <span class="name_c ftw5">{{ uMsg.name }}</span> 不在身边？</span
        >
        <span class="_model_btn" @click="copySignLink()">
          {{ origin == "ms" ? "分享给Ta" : "复制链接给Ta" }}</span
        >
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { wechatInitShareConfig, isWxChat } from "@/utils/wxJsSdk";
import { appShare } from "@/utils";
import { filterFieldValue, formatUrlSearch } from "@/methods/format.js";
export default {
  name: "NoticeShareMask",
  data() {
    return {
      isWxEnv: false,
    };
  },
  components: {},
  computed: {
    ...mapGetters({
      shareInfo: "home/shareInfo",
      productName: "varietyInfo/productName",
      applicant: "insert/applicant",
      revisitDomain: "page/revisitDomain",
    }),
    uMsg() {
      let msg = this.applicant;
      return msg;
    },
  },
  created() {
    this.isWxEnv = isWxChat();
    document.body.classList.add("van-overflow-hidden");
  },
  mounted() {},
  beforeDestroy() {
    let that = this;
    document.body.removeEventListener("touchmove", that.cancelEvent, {
      passive: false,
    });
    document.body.classList.remove("van-overflow-hidden");
  },
  methods: {
    getPageUrl(type = "") {
      let res = "";
      let ymUrl = `${this.revisitDomain}`;
      if (!ymUrl) {
        const insureEnv = process.env.VUE_APP_PRODFLAG;
        if (insureEnv === "wxou") {
          ymUrl = `https://wxou.mschn.cn/app_h5/insureservice/index.html`;
        } else {
          ymUrl = `https://wxou.mschn.cn/app_h5/testinsurance/insureservice/index.html`;
        }
      }
      let uqrys = formatUrlSearch();
      if (uqrys.indexOf("ptype") != -1) {
        uqrys = filterFieldValue(uqrys, "ptype");
      }
      res = `${ymUrl}${uqrys}&htype=hf&ptype=hf_detail&orderNum=${this.orderNum}`;
      if (type == "share") {
        res += `&share=1&skind=hf`;
      }
      return res;
    },
    writeNow() {
      let baseLink = this.getPageUrl();
      window.location.replace(`${baseLink}`);
    },
    /**分享链接 */
    copySignLink() {
      let nickName = this.uMsg.name ? ` ${this.uMsg.name} 先生/女士` : "客户";
      let ttText = `尊敬的${nickName}`,
        descText = `邀请您进行${this.productName}产品投保回访`;
      let baseLink = this.getPageUrl("share");
      if (this.isWxEnv) {
        wechatInitShareConfig(`${baseLink}`, `${ttText}`, `${descText}`);
      } else {
        let shareData = {
          icon: `${this.shareInfo.icon}`,
          url: `${baseLink}`,
          title: `${ttText}`,
          desc: `${descText}`,
        };
        appShare(shareData);
      }
    },
  },
};
</script>

<style lang="less" scoped>
.mask {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.45);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 25px;

  ._modal {
    width: 100%;
    border-radius: 10px;
    padding: 15px 24px;
    overflow: hidden;
    background: linear-gradient(0deg, #ffeaea 0%, #ffffff 100%);

    ._modal-content {
      display: flex;
      align-items: center;
      justify-content: center;
      padding: 30px;
    }

    ._modal-footer {
      display: flex;
      align-items: center;
      justify-content: space-between;
      width: 100%;
      height: 60px;
      font-weight: bold;
      padding: 0 12px;
      font-size: 15px;
      border-radius: 15px;
      background-color: #ffffff;

      .name_c {
        font-size: 16px;
        letter-spacing: 0px;
        line-height: 18px;
        color: rgba(255, 141, 26, 1);
      }

      ._model_btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 46%;
        height: 35px;
        font-size: 15px;
        border-radius: 35px;
        color: #ffffff;
        font-weight: 500;
        background: linear-gradient(270deg, #cb1800 0%, #ff462c 100%);

        &:active {
          opacity: 0.75;
        }
      }
    }
  }
}

.lineh1 {
  font-size: 18px;
  font-weight: bold;
  color: #1b1b1b;
}

.p_label {
  font-size: 12px;
  color: #1b1b1b;
  margin-top: 4px;

  i {
    color: #ff8d1a;
    font-size: 15px;
    font-style: normal;
    font-weight: 600;
  }
}
</style>
